

import 'package:flutter/cupertino.dart';

abstract class BaseState<T extends StatefulWidget> extends State<T> {

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(builder: (ctx,size)=>pageBuilder(context, getPageType(
        context)));
  }

  Widget pageBuilder(BuildContext context,PageType pageType);

  PageType getPageType(BuildContext context){
   
    double width = MediaQuery.of(context).size.width;
    double height = MediaQuery.of(context).size.height;
    // 判定屏幕比如果屏幕比超过 9：16 判定为手机
    if(width/height < 0.5625){
      return PageType.phone;
    }
    if(MediaQuery.of(context).size.width > 1000){
      return PageType.desktop;
    }else if(MediaQuery.of(context).size.width > 600){
      return PageType.tablet;
    }else{
      return PageType.phone;
    }
  }

}

enum PageType {
  phone,
  tablet,
  desktop,
}
